const async = require('async');
const request = require('request');
 
// 要测试的 URL 列表
const urls = [
    "http://example.com/api/endpoint1",
    "http://example.com/api/endpoint2",
    // ...
];
 
// 并发数量
const concurrencyCount = 10;
 
// 并发处理函数
const runRequest = function(url, callback) {
    request(url, function(error, response, body) {
        if (error) {
            callback(error);
        } else {
            callback(null, `Status code for ${url}: ${response.statusCode}`);
        }
    });
};
 
// 运行并发请求
async.mapLimit(urls, concurrencyCount, runRequest, function(err, results) {
    if (err) {
        console.error('An error occurred:', err);
    } else {
        console.log('Results:', results);
    }
});